package com.xiaoy.core.base.security.user.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.xiaoy.entity.BaseBean;
import com.xiaoy.util.store.config.ConfigTable;

@Entity
@Table(name=ConfigTable.Base.USER_TABLENAME)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class User extends BaseBean {

//	private long id;
	private String username;
	private String password;
	
	private UserBase userBase;
	
	private List<UserRole> userRoles; 
	
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public List<UserRole> getUserRoles() {
		return userRoles;
	}

	public void setUserRoles(List<UserRole> userRoles) {
		this.userRoles = userRoles;
	}

	@Embedded
	public UserBase getUserBase() {
		return userBase;
	}

	public void setUserBase(UserBase userBase) {
		this.userBase = userBase;
	}
	
}
